<template>
	<view class="shopList">
		<view class="shopList_one" v-for="(item,index) in shopArray" :key="index" @tap="$wanlshop.auth(`/pages/shop/index?id=${item.id}`)">
			<view class="shopList_oneImage">
				<image :src="item.avatar" mode="aspectFill"></image>
			</view>
			<view class="shopList_rightCount">
				<view class="shopList_title">
					<view class="title_left">
						{{item.shopname}}
					</view>
					<view class="title_right">
						<image src="../static/images/looklook.png" mode="aspectFill"></image>
					</view>
				</view>
				<view class="shopList_titledesc">
					{{item.description}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				page:1,
				last_page:1,
				total:0,
				shopArray:[],
			}
		},
		onLoad() {
			this.getshopList('init')
		},
		onPullDownRefresh() {
			setTimeout(()=>{
				uni.stopPullDownRefresh()
			},1500)
			this.getshopList('init')
		},
		onReachBottom() {
			if(this.page<this.last_page){
				this.page++
				this.getshopList()
			}
		},
		methods:{
			async getshopList(type){
				if(type=='init'){
					this.page=1
					this.shopArray=[]
				}
				await uni.request({
					url:"/wanlshop/shop/shopList",
					method:"POST",
					data:{
						page:this.page
					},
					success: (res) => {
						this.total=res.data.total
						this.last_page=res.data.last_page
						if(res.data.data.length){
							if(this.page==1){
								this.shopArray=res.data.data
							}else{
								this.shopArray=[...this.shopArray,...res.data.data]
							}
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.shopList{
		width: 100%;
		box-sizing: border-box;
		padding: 20rpx 24rpx;
		.shopList_one{
			width: 100%;
			box-sizing: border-box;
			padding: 22rpx;
			background-color: #ffffff;
			border-radius: 20rpx;
			display: flex;
			margin-bottom: 20rpx;
			.shopList_oneImage{
				margin-right: 20rpx;
				image{
					width: 182rpx;
					height: 182rpx;
					border-radius: 10rpx;
				}
			}
			.shopList_rightCount{
				width: 480rpx;
				box-sizing: border-box;
				padding:10rpx 20rpx 10rpx 0;
				.shopList_title{
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					.title_left{
						width: 350rpx;
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 30rpx;
						color: #333333;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
					.title_right{
						width: 130rpx;
						height: 46rpx;
						image{
							width: 130rpx;
							height: 46rpx;
						}
					}
				}
				.shopList_titledesc{
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 26rpx;
					color: #555555;
					margin-top: 25rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp:2;
					-webkit-box-orient: vertical;
				}
			}
		}
	}
</style>